package org.duoyi.striver;

import com.develop.jawin.COMException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
import org.duoyi.jdm.utils.JdmUtil;
import org.duoyi.striver.gui.controller.SideBarController;
import org.duoyi.striver.service.thread.WindowsFollower;

@Slf4j
public class StriverApplication extends Application {

    public static void main(String[] args) throws COMException {
        launch();
    }


    @Override
    public void start(Stage primaryStage) throws Exception {
        JdmUtil.setLibPath();
        primaryStage.setOnCloseRequest(event -> {
            WindowsFollower.stopping();
        });
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/views/SideBar.fxml"));
        Parent root = loader.load();
        SideBarController controller = loader.getController();
        SideBarController.init(controller);
        Scene scene = new Scene(root, 300, 768);
        primaryStage.setScene(scene);
        primaryStage.setResizable(false);
        primaryStage.setTitle("神武奋斗者");
        Image icon = new Image(getClass().getResourceAsStream("/icon/icon.png"));
        primaryStage.getIcons().add(icon);
        primaryStage.show();
        new WindowsFollower().start();
    }
}
